package org.example;

public class CallBillingService {
    /**
     * 计算通话费用
     * @param durationInSeconds 通话时长（秒）
     * @return 费用（美元）
     */
    public static double calculateCharge(int durationInSeconds) {
        if (durationInSeconds <= 0) {
            throw new IllegalArgumentException("通话时长必须大于0秒");
        }

        // 秒数向上取整到分钟
        int durationInMinutes = (int) Math.ceil(durationInSeconds / 60.0);

        if (durationInMinutes <= 20) {
            return durationInMinutes * 0.05;
        } else {
            return 1.00 + (durationInMinutes - 20) * 0.10;
        }
    }
}
